/*
 * RegisterMap.h
 *
 *  Created on: 2011-8-3
 *      Author: gexiao
 */

#ifndef REGISTERMAP_H_
#define REGISTERMAP_H_
#include "../Common.h"

/*
 * This is a single variable-size structure.  It may be allocated on the
 * heap or mapped out of a (post-dexopt) DEX file.
 *
 * 32-bit alignment of the structure is NOT guaranteed.  This makes it a
 * little awkward to deal with as a structure; to avoid accidents we use
 * only byte types.  Multi-byte values are little-endian.
 *
 * Size of (format==FormatNone): 1 byte
 * Size of (format==FormatCompact8): 4 + (1 + regWidth) * numEntries
 * Size of (format==FormatCompact16): 4 + (2 + regWidth) * numEntries
 */
struct RegisterMap {
	/* header */
	u1 format; /* enum RegisterMapFormat; MUST be first entry */
	u1 regWidth; /* bytes per register line, 1+ */
	u1 numEntries[2]; /* number of entries */

	/* raw data starts here; need not be aligned */
	u1 data[1];
};

bool dvmRegisterMapStartup(void);
void dvmRegisterMapShutdown(void);

/*
 *
 */
const u1* dvmRegisterMapGetLine(const RegisterMap* pMap, int addr);

/*
 * Release "data".
 *
 * If "pMap" points to a compressed map from which we have expanded a
 * single line onto the heap, this will free "data"; otherwise, it does
 * nothing.
 *
 * TODO: decide if this is still a useful concept.
 */
INLINE void dvmReleaseRegisterMapLine(const RegisterMap* pMap, const u1* data)
{}

INLINE const RegisterMap* dvmGetExpandedRegisterMap(Method* method) {

}
#endif /* REGISTERMAP_H_ */
